package com.aaronprj.common.entities.mbooks;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

import com.aaronprj.common.enums.StatusType;

@Entity
@NamedQueries( {
		@NamedQuery(name = "BookOrder.findAll", query = "SELECT e FROM BookOrder e"),
		@NamedQuery(name = "BookOrder.findByCustomer", query = "SELECT e FROM BookOrder e WHERE e.customerId = :customerId"),
		@NamedQuery(name = "BookOrder.findByOrderNo", query = "SELECT e FROM BookOrder e WHERE e.orderNo = :orderNo")})
public class BookOrder{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int id;
	private String orderNo;
	private int customerId;
	private String customerName;
	
	private StatusType status;
	private String shippingAddress;
	private String postCode;
	private String phone;
	private String email;
	private Date shippingDate;
	private double subtotal;
	private double serviceCharge;
	private double totalAmount;
	

	@Column(columnDefinition = "DATE DEFAULT CURRENT_DATE")
	private Date createDate;

	private List<OrderItem> orderItems = new ArrayList<OrderItem>();


	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

    public int getCustomerId() {
		return customerId;
	}

	public void setCustomerId(int customerId) {
		this.customerId = customerId;
	}

	public String getCustomerName() {
		return customerName;
	}

	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public StatusType getStatus() {
		return status;
	}

	public void setStatus(StatusType status) {
		this.status = status;
	}

	@Column(length=1000)
	public String getShippingAddress() {
		return shippingAddress;
	}

	public void setShippingAddress(String shippingAddress) {
		this.shippingAddress = shippingAddress;
	}

	public String getPostCode() {
		return postCode;
	}

	public void setPostCode(String postCode) {
		this.postCode = postCode;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Date getShippingDate() {
		return shippingDate;
	}

	public void setShippingDate(Date shippingDate) {
		this.shippingDate = shippingDate;
	}

	public double getSubtotal() {
		return subtotal;
	}

	public void setSubtotal(double subtotal) {
		this.subtotal = subtotal;
	}

	public double getServiceCharge() {
		return serviceCharge;
	}

	public void setServiceCharge(double serviceCharge) {
		this.serviceCharge = serviceCharge;
	}

	public double getTotalAmount() {
		return totalAmount;
	}

	public void setTotalAmount(double totalAmount) {
		this.totalAmount = totalAmount;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@OneToMany(mappedBy="bookOrder",fetch=FetchType.EAGER)
	public List<OrderItem> getOrderItems() {
		return orderItems;
	}

	public void setOrderItems(List<OrderItem> orderItems) {
		this.orderItems = orderItems;
	}


}
